<?php

namespace app\xwam\model;

/**
 * 外观管理 模型类
 *
 * @since VER:1.0; DATE:2017-3-27; AUTHOR:SoChishun; EMAIL:14507247@qq.com; DESC:Added.
 */
class CustomThemeModel extends AppbaseModel {

    protected $table = 't_porg_sys_skin';


    public function saveSkin() {
        $validator = array(
            array('title', 'require', '名称无效!', self::MUST_VALIDATE, 'regex', self::MODEL_INSERT),
            array('user_name', 'require', '用户无效!', self::EXISTS_VALIDATE, 'regex', self::MODEL_BOTH),
        );
        if (!$this->validate($validator)->create()) {
            return $this->returnMsg(false, $this->getError());
        }
        if (empty($this->id)) {
            unset($this->data['id']);
            $result = $this->add();
        } else {
            $result = $this->save();
        }
        return $this->returnMsg($result);
    }

    function deleteSkin($id) {
        $result = $this->where(array('id' => array('in', $id)))->delete();
        return $this->returnMsg($result);
    }

}
